<template>
  <el-dialog
    v-model="props.openEdit"
    title="修改车次"
    @close="emit('closeEdit', false)"
  >
    <el-form :model="props.item">
      <el-form-item label="车长" :label-width="formLabelWidth">
        <el-input v-model="props.item.name" autocomplete="off" />
      </el-form-item>
      <el-form-item label="总座位数" :label-width="formLabelWidth">
        <el-input v-model="props.item.sum" autocomplete="off" />
      </el-form-item>
      <el-form-item label="车厢数量" :label-width="formLabelWidth">
        <el-input v-model="props.item.count" autocomplete="off" />
      </el-form-item>
      <el-form-item label="限乘人数" :label-width="formLabelWidth">
        <el-input v-model="props.item.total" autocomplete="off" />
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="handleCancel">取消</el-button>
        <el-button type="primary" @click="handleOk"> 确定 </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup>
import { onMounted, reactive, ref, toRefs } from "vue";
import { storeToRefs } from "pinia";
import { useStore } from "@/store/index.js";

const store = useStore();
const props = defineProps(["openEdit", "item"]);
const { openEdit, item } = toRefs(props); // 父传子数据变成响应式
const formLabelWidth = "140px";
const emit = defineEmits(["closeEdit"]);
const handleCancel = () => {
  emit("closeEdit", false);
};
const handleOk = () => {
  emit("closeEdit", false);
};
</script>
<style scoped>
.el-button--text {
  margin-right: 15px;
}
.el-select {
  width: 300px;
}
.el-input {
  width: 300px;
}
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>
